package com.demo.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;

import com.demo.enums.VtePreventiveDoctorAdviceTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * vte预防处置医嘱
 * @author zm
 * @since 2020-11-27
 */
@Data
@TableName("pd_vte_preventive_doctor_advice")
@ApiModel(value="VtePreventiveDoctorAdvice对象", description="vte预防处置医嘱")
public class VtePreventiveDoctorAdvice implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "医嘱处理编号")
    @TableId(value = "doctor_advice_id", type = IdType.AUTO)
    private Integer doctorAdviceId;

    @ApiModelProperty(value = "vte诊断序列号")
    @TableField("vte_preventive_id")
    @NotNull(message = "vte诊断序列号不能为空")
    private Integer vtePreventiveId;

    @ApiModelProperty(value = "医嘱内容jeson对象存储")
    @TableField("advise_cotent")
    @NotBlank(message = "医嘱内容不能为空")
    private String adviseCotent;

    @ApiModelProperty(value = "医嘱类型1药物2物理")
    @TableField("advise_type")
    @NotNull(message = "医嘱类型不能为空")
    private Integer adviseType;

    @ApiModelProperty(value = "医嘱时限  1.长期  2.临时")
    @TableField("validity_length")
    private Integer validityLength;

    @ApiModelProperty(value = "停止人")
    @TableField("stoped_user_id")
    private Integer stopedUserId;

    @ApiModelProperty(value = "停止时间")
    @TableField("stoped_user_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date stopedUserTime;

    @ApiModelProperty(value = "作废时间")
    @TableField("deleted_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deletedTime;

    @ApiModelProperty(value = "作废人ID号")
    @TableField("deleted_user_id")
    private Integer deletedUserId;

    @ApiModelProperty(value = "创建时间&开具时间")
    @TableField(value = "created_time",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    @ApiModelProperty(value = "创建人ID号")
    @TableField("created_user_id")
    @NotNull(message = "创建人ID不能为空")
    private Integer createdUserId;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "updated_time",fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updatedTime;

    @ApiModelProperty(value = "更新人ID号")
    @TableField("updated_user_id")
    private Integer updatedUserId;

    @ApiModelProperty(value = "医嘱状态 1.未停止  2.已停止  默认为：1")
    @TableField(value = "status")
    private Integer status;

    @ApiModelProperty(value = "患者ID")
    @TableField(value = "patient_id")
    private Integer patientId;


    @ApiModelProperty(value = "推荐剂量")
    @TableField("recommend_dosage")
    private String recommendDosage;

    @ApiModelProperty(value = "单位")
    @TableField("unit")
    private String unit;

    @ApiModelProperty(value = "推荐用法")
    @TableField("way")
    private String way;

    @ApiModelProperty(value = "推荐频率")
    @TableField("way_gap")
    private String wayGap;

    @ApiModelProperty(value = "药物ID")
    @TableField("drug_id")
    private Integer drugId;

    public VtePreventiveDoctorAdvice() {
    }

    public VtePreventiveDoctorAdvice(VtePreventiveMedicine preventiveMedicine, VtePreventive vtePreventive,  Integer createdUserId) {
        this.vtePreventiveId = vtePreventive.getVtePreventiveId();
        this.adviseCotent = preventiveMedicine.getName();
        this.adviseType = VtePreventiveDoctorAdviceTypeEnum.YAO_WU.getValue();
        this.createdTime = new Date();
        this.createdUserId = createdUserId;
        this.patientId = vtePreventive.getPatientId();
        if (preventiveMedicine.getRecommendDosage() != null) {
            this.recommendDosage = preventiveMedicine.getRecommendDosage().toString();
        }
        this.unit = preventiveMedicine.getUnit();
        this.way = preventiveMedicine.getWay();
        this.wayGap = preventiveMedicine.getWayGap();
        this.drugId = preventiveMedicine.getMedicineId();
        if (vtePreventive.getCreatedUserId() != null) {
            this.createdUserId = vtePreventive.getCreatedUserId();
            this.updatedUserId = vtePreventive.getCreatedUserId();
        }
        if (vtePreventive.getUpdatedUserId() != null) {
            this.createdUserId = vtePreventive.getUpdatedUserId();
            this.updatedUserId = vtePreventive.getUpdatedUserId();
        }
    }

    public VtePreventiveDoctorAdvice(VtePreventive vtePreventive, String preventiveTabooAdvise, VtePreventiveDoctorAdviceTypeEnum adviceType) {
        this.adviseCotent = preventiveTabooAdvise;
        this.vtePreventiveId = vtePreventive.getVtePreventiveId();
        this.adviseType = adviceType.getValue();
        this.patientId = vtePreventive.getPatientId();
        if (vtePreventive.getCreatedUserId() != null) {
            this.createdUserId = vtePreventive.getCreatedUserId();
            this.updatedUserId = vtePreventive.getCreatedUserId();
        }
        if (vtePreventive.getUpdatedUserId() != null) {
            this.createdUserId = vtePreventive.getUpdatedUserId();
            this.updatedUserId = vtePreventive.getUpdatedUserId();
        }
    }

}
